package edu.hawaii.ics414;

import java.util.HashMap;
import java.util.Map;
import android.os.AsyncTask;

/**
 * Creates a new user in the system
 * 
 * @author Matthew Mizumoto
 * 
 */

public class CreateUser extends AsyncTask<String, Void, String> {
  @Override
  /*
   * Required by the AsyncTask class. Sends data to the appropriate php page for updates/queries
   * (non-Javadoc)
   * 
   * @params params A variable amount of Strings to send as form data.
   * 
   * @see android.os.AsyncTask#doInBackground(Params[])
   */
  protected String doInBackground(String... params) {
    String username = params[0];
    String password = params[1];
    String firstName = params[2];
    String lastName = params[3];
    String email = params[4];

    Map<String, String> requestParams = new HashMap<String, String>();
    requestParams.put("username", username);
    requestParams.put("password", password);
    requestParams.put("first_name", firstName);
    requestParams.put("last_name", lastName);
    requestParams.put("email", email);
    String response =
        Ajax.send("http://ratethatgame.web44.net/ics414/createAccount.php", requestParams);

    return response;
  }
}
